#ifndef COMMODITYSALE_H
#define COMMODITYSALE_H

#include <QWidget>
#include "commodity.h"
#include "saledetail.h"
//#include "salesorderform.h"
#include "saleorderform.h"
#include "systemset.h"
#include "personmember.h"

class LockScreen;
class InquireSql;
class InquirePurchaseCommodity;
class ModifyPriceDiscount;
class Checkout;
class InquireMemberProfile;
class SystemSet;
class PrintMemberPassword;

enum LastClickCommoditySale {lineEditInquireCommodity, lineEditMembershipNumber,
                tableWidgetSale};

enum PriceMode {RetailPrice,
                  RetailPrice_Multiply_CommodityDiscount,
                  RetailPrice_Multiply_MemberDiscount,
                  RetailPrice_Multiply_CommodityDiscount_Multiply_MemberDiscount,
                  MemberPrice,
                  MemberPrice_Multiply_CommodityDiscount,
                  MemberPrice_Multiply_MemberDiscount,
                  MemberPrice_Multiply_CommodityDiscount_Multiply_MemberDiscount};

namespace Ui {
class CommoditySale;
}

class CommoditySale : public QWidget
{
    Q_OBJECT
    
public:
    explicit CommoditySale(QWidget *parent = 0);
    ~CommoditySale();
    bool eventFilter(QObject *target, QEvent *event);
    void setFocus();
    
signals:
    void returnHomePage();

public slots:
    void slotUpdateSystemSettingsInformation();

private slots:
    void on_pushButtonLockScreen_clicked();

    void on_pushButtonInquireCommodity_clicked();

    void slotDisplayCommodityInformation(QString);

    void on_pushButtonCheckout_clicked();

//    void on_tableWidgetSale_cellChanged(int row, int column);

    void on_tableWidgetSale_cellDoubleClicked(int row, int);

    void on_pushButtonInquireMember_clicked();

    void slotJudgementMemberPassword(QString);

    void slotDisplayMemberInformation(QString);

    void on_pushButtonClear_clicked();

    void slotUpdateSalesPriceDiscount(const SaleDetail&);

//    void on_tableWidgetSale_cellClicked(int row, int column);

    void on_pushButtonClearMember_clicked();

    void on_pushButtonDelete_clicked();

//    void on_lineEditInquireCommodity_textChanged(const QString &arg1);

//    void slotCheckOut();

    void slotInit();

private:
    void setQtableWidgetHeader();
    void displaySalesCommodityInformation();
//    void updateSalesCommodityInformation();
    void setTableWidgetColor();
    void addSalesCommodity(QString);
    void HandleLineEditCommodityInformation();
    void handleLineEditMembershipNumber();
    void setSalesOrderFormNumber();
    void eliminationPushButtonBorder();
//    void updateTotalSales();
    Ui::CommoditySale *ui;
    LockScreen *m_lockScreen;
    commodityList m_commodityList;
    InquirePurchaseCommodity *m_inquirePurchaseCommodity;
    InquireSql *m_sql;
    saleDetailList m_currentTableWidgetList;
    ModifyPriceDiscount *m_modifyPriceDiscount;
    Checkout *m_checkout;
    InquireMemberProfile *m_inquireMemberProfile;
    SaleOrderFormList m_salesOrderFormList;
    SystemSet m_systemSet;
    int m_lastClick;
    PrintMemberPassword *m_printMemberPassword;
    QString m_memberDiscount;
    bool m_isAddSubQuantity;
    memberList m_memberList;
    bool m_updateSaleCommodityInformation;
};

#endif // COMMODITYSALE_H
